package com.icare.shop.server.config;

/**
 * <pre>
 *    author  : tianhaibo
 *    email   : tianhaibo@jshuii.com
 *    time    : 2020/5/11   15:52
 *    desc    :
 *    version : v1.0
 * </pre>
 */

public class MyClassLoader extends ClassLoader {

    private static MyClassLoader classLoader = null;

    public static Class<?> loadClass(String name,byte[] data) {
        //下载类文件
        MyClassLoader  newClassLoader = new MyClassLoader();
        try {
            Class<?> aClass1 = null;
            try {
                aClass1 = newClassLoader.loadClass(name, true);
            } catch (Exception e) {
            }
            if(aClass1!=null){
                return aClass1;
            }else {
                return newClassLoader.defineClass(name, data, 0, data.length);
            }
        } catch (Exception e) {
            return null;
        }
    }

}
